<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">

	</head>

	<body>

		<div class="layui-fluid">
			<div class="layui-row" id="view">
				<form class="layui-form test_edit" lay-filter="test_detail">
					<div class="layui-card">
						<div class="layui-card-body">
							<div class="layui-form-item">
								<label class="layui-form-label">机具序列号：</label>
								<div class="layui-input-block">
									<textarea  name="pos_sn" placeholder="机具序列号" class="layui-textarea"></textarea>
									<!-- <p class="layui_p" id="pos_sn"></p> -->
									<!-- <input type="hidden" name="pos_sn"/> -->
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><text class='text_red_color'>*</text>返现金额：</label>
								<div class="layui-input-block">
									<input type="text" name="back_amount" lay-verify="required|number" placeholder="请输入返现金额" autocomplete="off"
									 class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">购机红包：</label>
								<div class="layui-input-block">
									<input type="text" name="back_packet" lay-verify="number"  placeholder="请输入购机红包" autocomplete="off"
									 class="layui-input">
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">押金金额：</label>
								<div class="layui-input-block">
									<input type="text" name="deposit_amount" placeholder="请输入押金金额" autocomplete="off"
									 class="layui-input">
								</div>
							</div>
							<div class="layui-form-item"  id="back_policy">
								<div class="layui-inline">
									<label class="layui-form-label">订货政策 <span style="color: red;">*</span>：</label>
									<div class="layui-input-inline agent_type">
										<input type="radio" name="policy" value="5" checked="checked" title="5">
										<div class="layui-unselect layui-form-radio layui-form-radioed">
											<i class="layui-anim layui-icon"></i>
											<div>5</div>
										</div>
										<input type="radio" name="policy" value="50" title="50">
										<div class="layui-unselect layui-form-radio">
											<i class="layui-anim layui-icon"></i>
											<div>50</div>
										</div>
									</div>
								</div>
							</div>
							
							<div class="layui-form-item">
								<label class="layui-form-label">返现到期时间：</label>
								<div class="layui-input-block">
									<input type="text" class="layui-input" name="back_expire" autocomplete="off" id="test1" placeholder="yyyy-MM-dd">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">返现到期金额：</label>
								<div class="layui-input-block">
									 <input type="text" name="back_expire_amount"   placeholder="返现到期金额" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">到期购机红包：</label>
								<div class="layui-input-block">
									 <input type="text" name="back_expire_packet"   placeholder="到期购机红包" autocomplete="off" class="layui-input">
								</div>
							</div>
							
						</div>
					</div>

					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
								<button class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			var _data = {
				 pos_sn: getParam('pos_sn')
			}
			// console.log(_data.id);
		
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laytpl', 'laydate', 'layedit'], function() {
				var $ = layui.$,
					admin = layui.admin,
					layedit = layui.layedit,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					form = layui.form;

				initproductshow('option')
				img_arr1 = [];
				img_arr2 = [];

				var index = layedit.build('demo_editor', {
					tool: ['strong' //加粗
						, 'italic' //斜体
						, 'underline' //下划线
						, 'del' //删除线

						, '|' //分割线

						, 'left' //左对齐
						, 'center' //居中对齐
						, 'right' //右对齐
						, 'link' //超链接
						, 'unlink' //清除链接
						, 'face' //表情
					]
				});
				if(_data.pos_sn){
					initdata()
				}
				laydate.render({
					elem: '#test1'
				});

				on_off_show('radio')
				if(_data.id) {
					initdata();
				} else {
					initnews_catshow('option');
				}

				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					_data.pos_sn = _data.pos_sn.replace(/ /g,'')
					
					layer.confirm('确定提交数据？', function() {
						loading();
						if(_data.back_expire == null || _data.back_expire =='' || _data.back_expire == undefined){
							delete _data.back_expire
						}
						submitdata(server.updatepos);
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert('操作成功', function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
								layer.closeAll('loading');
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

				window.searchdata = function(type) {
					layer.open({
						type: 2,
						title: '选择',
						shadeClose: false,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['90%', '90%'],
						content: '../../model/list.html',
						end: function() {},
						success: function() {}
					});
				}
				
				$('textarea[name=pos_sn]').bind('input propertychange', function(){  
				    var textarea_val = $("textarea[name=pos_sn]").val().replace(/\n/g,",");;
					$("textarea[name=pos_sn]").val(textarea_val)
				    // console.log(length);
				}); 
				function initdata() {
					$.get(server.detailpos, _data, function(res, status) {
						if (status == 'success') {
							if (res.code == 0) {
								var data = res.ls_pos
								form.val("test_detail", data.data);
								form.render();
								
							} else {
								layer.msg(res.msg);
							}
						} else {
							layer.msg('服务器连接错误');
						}
					});
				}

			});
		</script>
	</body>

</html>